package com.mfsoft.camera;

import com.mfsoft.net.MyFunctions_THI;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MyProfileActivity extends Activity {

	TextView txttendangnhap,txtgmail;
	Button btnlogout,btncapnhatthongtin;
	MyFunctions_THI myFunctions_THI; 
	String prefname="my_data";
	Context context;
	private SharedPreferences preferences;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_profile);
		txttendangnhap = (TextView)findViewById(R.id.txttendangnhap1);
		txtgmail = (TextView)findViewById(R.id.txtgmail1);
		preferences = getSharedPreferences(prefname,context.MODE_PRIVATE);		
	    String username =preferences.getString("username","");
	    String gmail = preferences.getString("gmail", "");
	        txttendangnhap.setText(username);
	        txtgmail.setText(gmail);
	        btnlogout = (Button)findViewById(R.id.btnlogout);
	        myFunctions_THI = new MyFunctions_THI(getApplicationContext());
	        btnlogout.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					myFunctions_THI.LogOut();
					Intent i = new Intent(getApplicationContext(), MainActivity.class);
					startActivity(i);
					finish();
				}
			});
		btncapnhatthongtin = (Button)findViewById(R.id.btnthongtin);
		btncapnhatthongtin.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(), UpdateMyProfileActivity.class);
				startActivity(i);
				finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.my_profile, menu);
		return true;
	}

}
